<?php 
if (($section != "comments") && ($_POST['lo_text'] == "")) header("location:../index.php?section=clo&action=".$action."&cid=".$cid."&vid=".$_POST['vid']."&mid=".$_POST['mid']."&pdid=".$_POST['pdid']."&msg=2"); 
	
	if ($section != "comments") {
	if ($action == "add") {
		$insertSQL = sprintf("INSERT INTO learning_outcomes 
			(
			cid, 
			del_num, 
			mid,
			lo_text
			) 
			VALUES 
			(%s, %s, %s, %s)", 	
				GetSQLValueString($cid, "int"),
				GetSQLValueString($_POST['del_num'], "int"),
				GetSQLValueString($_POST['mid'], "int"),
				GetSQLValueString($_POST['lo_text'], "text")
				);
  						
		mysql_select_db($database, $connection);
  		$result1 = mysql_query($insertSQL, $connection) or die(mysql_error());
		//echo $insertSQL."<br>";
		
		$query_id = sprintf("SELECT id FROM learning_outcomes WHERE cid='%s' AND mid='%s' AND del_num='%s' ORDER BY id DESC", $cid, $_POST['mid'], $_POST['del_num']);
		$id = mysql_query($query_id, $connection) or die(mysql_error());
		$row_id = mysql_fetch_assoc($id);
		
		$insertGoTo = "../index.php?section=clo&action=confirm&cid=".$cid."&mid=".$_POST['mid']."&del_num=".$_POST['del_num']."&id=".$row_id['id']."&modal_window=".$modal_window."&msg=3";
		//if ($section == "admin") $insertGoTo = "../index.php?section=list&msg=2";
		header(sprintf("Location: %s", $insertGoTo));
	}
	
	if ($action == "edit") {
		$query_pd = sprintf("SELECT * FROM project_deliverable WHERE del_num='%s' ORDER BY vid DESC LIMIT 1", $_POST['del_num']);
		$pd = mysql_query($query_pd, $connection) or die(mysql_error());
		$row_pd = mysql_fetch_assoc($pd);
		$updateSQL = sprintf("UPDATE learning_outcomes 
			SET 
			cid=%s, 
			del_num=%s, 
			mid=%s,
			lo_text=%s 
			WHERE id=%s", 
				GetSQLValueString($cid, "int"),
				GetSQLValueString($_POST['del_num'], "int"),
				GetSQLValueString($row_pd['mid'], "int"),
				GetSQLValueString($_POST['lo_text'], "text"),
				GetSQLValueString($id, "int")
			);
  						
		mysql_select_db($database, $connection);
  		$result1 = mysql_query($updateSQL, $connection) or die(mysql_error());
		// echo $updateSQL;
		if ($go == "no") $updateGoTo = "../index.php?section=clo&action=confirm&cid=".$cid."&vid=".$_POST['vid']."&mid=".$_POST['mid']."&del_num=".$_POST['del_num']."&id=".$id."&msg=3&modal_window=".$modal_window;
		//elseif ($go == "review") $updateGoTo = "../index.php?section=proposal_reveiw&cid=".$cid."&msg=5";
		//elseif ($go == "detail") $updateGoTo = "../index.php?section=view_proposal&dbTable=learning_outcomes&cid=".$cid."&id=".$id."&msg=2";
		//elseif ($go == "overview") $updateGoTo = "../index.php?section=view_proposal&cid=".$cid."&msg=2#lo";
		//else $updateGoTo = "../index.php?section=clo&action=view&cid=".$cid."&msg=4";
		//if ($section == "admin") $insertGoTo = "../index.php?section=list&msg=2";
		else $updateGoTo = $updateGoTo."&msg=5&modal_window=".$modal_window;
		header(sprintf("Location: %s", $updateGoTo));
		}
	}
?>